package com.itheima.controller;

import com.itheima.pojo.Goods;
import com.itheima.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.awt.print.Book;
import java.util.List;

/**
 * @Name GoodsController
 * @Author BaiXin
 * @Date 2022-10-19 20:57
 */

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @RequestMapping("/selectAll")
    public List<Goods> selectAll() {
        return goodsService.selectAll();
    }

    @RequestMapping("/delete/{id}")
    public void selectAll(@PathVariable Integer id) {
        goodsService.deleteById(id);
    }

    @RequestMapping("update")
    public void update(@RequestBody Goods goods){
        goodsService.update(goods);
    }


    @RequestMapping("add")
    public void add(@RequestBody Goods goods){
        goodsService.add(goods);
    }
}
